# Contributor: Chloe Kudryavtsev <toast@toast.cafe>
# Maintainer: Chloe Kudryavtsev <toast@toast.cafe>
pkgname=procs
pkgver=0.12.3
pkgrel=0
pkgdesc="Modern replacement for ps written in Rust"
url="https://github.com/dalance/procs"
arch="all !s390x !riscv64" # limited by rust/cargo
license="MIT"
makedepends="cargo"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="procs-$pkgver.tar.gz::https://github.com/dalance/procs/archive/v$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	# Default features enables "docker" feature that doubles the size of
	# the resulting binary with unnecessary bloat!
	cargo build --release --frozen --no-default-features

	# generate shell completions
	target/release/procs --completion bash
	target/release/procs --completion fish
	target/release/procs --completion zsh
}

check() {
	cargo test --frozen --no-default-features
}

package() {
	install -Dm755 target/release/procs "$pkgdir"/usr/bin/procs

	# install completions
	install -Dm644 procs.bash "$pkgdir"/usr/share/bash-completion/completions/procs
	install -Dm644 procs.fish "$pkgdir"/usr/share/fish/completions/procs.fish
	install -Dm644 _procs "$pkgdir"/usr/share/zsh/site-functions/_procs
}

sha512sums="
351433d85eddcf988bcb0f7cd0110cb0bf3e2135cbc742898c134d7746820dfb4e305813fa1386e67a48095f43edff0a9a685ca00be00187b0af875b39ee3463  procs-0.12.3.tar.gz
"
